package com.yunfei.core.utils.unicode_x;

/**
 *@author 王译萱
 *@date 2018/5/9 9:51
 *@param
 *@return
 *@Description调数字格式
 */

public class MoneyFormat {
    private static MoneyFormat moneyFormat;

    public static MoneyFormat getMoneyFormat() {
        MoneyFormat moneyFormat = new MoneyFormat();
        return moneyFormat;
    }
    public String doFormat(String money){
        Integer length = money.length();
        String temp = "";
        for (int i = 1; i < length / 3; i++) {
            temp = money.substring(0, -4 * i + 1);    //从后往前数，来获取前面的字符串
            temp =temp.replace(temp, temp + ',');    //给前面的字符串后面加一个逗号
            temp =temp.replace(",.",".").replace(".,",".");
        }
        return temp;
    }

    public static void main(String[] args) {
        MoneyFormat.getMoneyFormat().doFormat("12312313212313.00123");
    }
}
